package com.cn.jx.manager.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.cn.jx.manager.po.DataGrid;

/**
 * <p>DataGridRepository 数据表格mapper层操作数据库的接口
 *<p>实现<{@link BaseIdRepository <tt>BaseIdRepository</tt>}
 * 
 * @author <h1>jiangxu2  2019年11月21日</h1>
 * @version v1.11.20.2019
 * @since 1.0
 * 
 */
public interface DataGridRepository extends JpaRepository<DataGrid,String>,JpaSpecificationExecutor<DataGrid>{
	
	/**<p>定义HQL查询 根据表格类型查询对应的表格 {@link DataGrid} */
	@Query("from DataGrid  where gridType=:gridType order by sort asc  ")
	public List<DataGrid> findDataGridByType(@Param(value = "gridType") String gridType);
	
	/**<p>定义HQL查询 根据表格类型和开关查询所有开这的或关闭的表格字段查询对应的表格 {@link DataGrid} */
	@Query("from DataGrid  where gridType=:gridType and switchOnOff=:switchOnOff order by sort asc ")
	public List<DataGrid> findDataGridByTypeAndOn(@Param(value = "gridType") String gridType,@Param(value = "switchOnOff") String switchOnOff);
	
	@Query("select count(1) from DataGrid ")
	public int findAllCount();
	
	@Query("select field from DataGrid  where gridType=:gridType ")
	public List<String> findFieldByType(@Param(value = "gridType") String gridType);
}
